Contributors: Karim Pichara, Daniel Acuña, Nicolás Castro, Cristobal Mackenzie, Andrés Riveros and Ming Zhu
A time series is a sequence of observations (data points) that are arranged based on the time of their ocurrence. The hourly measurement of wind speeds in meteorology, the minute by minute recording of electrical activity along the scalp in electroencephalography, the weekly changes of stock prices in finances, are just some examples among many others.
Some of the main properties one would expect to find in a time series are [1]:
The study and analysis of time series can have multiple ends: get a better understanding of the mechanism generating the data, predict future outcomes and behaviours, classification and characterization of events, etc.
animation.FuncAnimation(fig, animate, init_func=init,
frames=100, interval=200, blit=True)
In time-domain astronomy, data gathered from the telescopes is usually represented in the form of light-curves. These are time series that show the brightness variation of an object through a period of time (for a visual representation see video below). Based on the variability characteristics of the light-curves, stars can be classified into different groups (quasars, long period variables, eclipsing binaries, etc.) and consequently be studied in depth independentely.
In order to characterize this variability, most of the existing methods use machine learning algorithms that build their decision on the light-curves features. Features, the topic of the following work, are numerical descriptors that aim to characterize and distinguish the different variability classes. They can go from basic statistical measures such as the mean or the standard deviation, to complex time-series characteristics such as the autocorrelation function.
In this document we present a library with a compilation of some of the existing light-curve features. The main goal is to create a collaborative and open tool where every user can characterize or analyze an astronomical photometric database while also contributing to the library by adding new features. However, it is important to highlight that this library is not restricted to the astronomical field and could also be applied to any kind of time series.
Our vision is to be capable of analyzing and comparing light-curves from all the available astronomical databases in a standard and universal way. This would facilitate and make more efficient tasks as modelling, classification, data cleaning, outlier detection and data analysis in general. Consequently, when studying light-curves, astronomers and data analysts would be on the same wavelength and would not have the necessity to find a way of comparing or matching different features. In order to achieve this goal, the library should be run in every existent survey (MACHO, EROS, Ogle, LSST, etc) and the results should be ideally shared in the same open way as this library. We invite every user having a survey database to use our library and to contribute with the results in favour of our goal of creating a universal astronomical survey.
The video below shows how the data gathered from the brightness intensity of a star through time results on a light-curve. In this particular case we are observing a complex triple system in which three stars have mutual eclipses as each of the stars gets behind or in front of the others.
from IPython.display import YouTubeVideo
YouTubeVideo('qMx4ozpSRuE', width=750, height=360, align='right')
The following picture presents example light-curves of each class in the MACHO survey. The x-axis is the modified Julian Date (MJD), and the y-axis is the MACHO B-magnitude.
picture = Image(filename='curvas_ejemplos11.jpg')
picture.size = (100, 100)
picture
The library is coded in python and can be downloaded for free from the github website https://github.com/isadoranun/tsfeat. The main idea is that any user can run it in its own database but can also add new features through the github system. For a quick guide on how to use github visit https://guides.github.com/activities/hello-world/.
The library receives as minimum input the light-curve magnitude (light intensity) through time and returns as output a vector with the calculated features. The structure is divided into two main parts. Part one, Feature.py, is a wrapper class that allows the user to select the category of the features to be calculated or to specify a list of them. Part two, FeatureFunciontLib.py, contains the actual code for calculating the features. Each feature has its own class with at least two functions:
init: receives the necessary inputs (other than the magnitude) for the feature calculation (ex: observational error, observational time, magnitude in a different color band, etc.). It also defines the feature category, "times-series" or "basic".
fit: returns the calculated feature. The output can only take one value; features like the autocorrelation function must consequently be summarized in one single scalar.
The following code is an example of a class in FeatureFunciontLib.py that calculates the color feature (difference of the mean magnitude in two different bands) :
class B_R(Base):
#Lightcurve average color
#mean(B) - mean(R)
def __init__(self, second_data):
self.category='timeSeries'
if second_data is None:
print "please provide another data series to compute B_R"
sys.exit(1)
self.data2 = second_data
def fit(self, data):
return np.mean(data) - np.mean(self.data2)
If the user wants to contribute with feature(s) to the library, it (they) must be added to FeatureFunctionLib.py following the explained format. There is no need to modify Feature.py.
The library we created allows the user to either choose the specific features of interest to be calculated or to calculate them all simultaneously. Also, the features can be calculated based on their category: "basic" or "time series".
By default the library receives only the magnitude data as input. As explained above, some features need extra data as the times of measurement or the associated error, this must be specified as a parameter of the feature.
The list of all the possible features with their corresponding categories, parameters and literature source is presented in the following table:
make_table(FeaturesList)
apply_theme('basic')
set_global_style(float_format='%0.3E')
Some examples of how to use the library are presented next:
a = FeatureSpace(featureList=['Std','StetsonL'], StetsonL=[aligned_second_data, aligned_data])
a=a.calculateFeature(data)
Table(a)
a = FeatureSpace(category=['timeSeries'], Automean=[0,0], StetsonL=[aligned_second_data, aligned_data] , B_R=second_data, Beyond1Std=error, StetsonJ=[aligned_second_data, aligned_data], MaxSlope=mjd, LinearTrend=mjd, Eta_B_R=[aligned_second_data, aligned_data, aligned_mjd], Eta_e=mjd, Q31B_R=[aligned_second_data, aligned_data], PeriodLS=mjd, Psi_CS=mjd, CAR_sigma = [mjd, error**2], SlottedA = [mjd, 4])
a=a.calculateFeature(data)
Table(a)
a = FeatureSpace(category='all',featureList=None, Automean=[0,0], StetsonL=[aligned_second_data, aligned_data] , B_R=second_data, Beyond1Std=error, StetsonJ=[aligned_second_data, aligned_data], MaxSlope=mjd, LinearTrend=mjd, Eta_B_R=[aligned_second_data, aligned_data, aligned_mjd], Eta_e=mjd, Q31B_R=[aligned_second_data, aligned_data], PeriodLS=mjd, Psi_CS=mjd, CAR_sigma=[mjd, error], SlottedA = [mjd, 4])
a=a.calculateFeature(data)
Table(a)
In order to calculate the features, it is first necessary to import the data in the right format. A light-curve should be an array composed by at least four vectors: magnitude in two different bands, time of measurement and the associated observational error. For example, the function LeerLC_MACHO() receives a MACHO id (object id assigned in the MACHO survey) as an input and returns the following output:
A demostration of how to import a MACHO light-curve is presented below. Besides opening the file, the data is:
#We open the ligth curve in two different bands
lc_B = LeerLC_MACHO('lc_1.3444.614.B.mjd') #58.6272.729 1.3444.614 1.4652.1527
lc_R = LeerLC_MACHO('lc_1.3444.614.R.mjd')
#We import the data
[data, mjd, error] = lc_B.leerLC()
[data2, mjd2, error2] = lc_R.leerLC()
#We preprocess the data
preproccesed_data = Preprocess_LC(data, mjd, error)
[data, mjd, error] = preproccesed_data.Preprocess()
preproccesed_data = Preprocess_LC(data2, mjd2, error2)
[second_data, mjd2, error2] = preproccesed_data.Preprocess()
#We synchronize the data
if len(data) != len(second_data):
[aligned_data, aligned_second_data, aligned_mjd] = Align_LC(mjd, mjd2, data, second_data, error, error2)
It is sometimes helpful to visualize the data before processing it. For a representation of the light curve, we can plot it as follows:
Color = [ 1 ,0.498039, 0.313725];
p = plt.plot(mjd, data, '*-', color=Color)
plt.xlabel("MJD")
plt.ylabel("Magnitude")
plt.gca().invert_yaxis()
print np.std(data)/np.mean(data)
Note: for periodic light-curves we are able to transform the photometric time series into a single light-curve in which each period is mapped onto the same time axis as follows: $$ t'=\{\frac{t-t_0}{T}\} $$
where $T$ is the period, $t_0$ is an arbitrary starting point and the symbol {} represents the non-integer part of the fraction. This process produces a folded light-curve on an x-axis of folded time that ranges from 0 to 1. The corresponding folded light-curve of the previous example is shown next:
Color = [ 0.392157, 0.584314 ,0.929412];
T = 2 * 0.93697446
new_b=np.mod(mjd, T) / T;
idx=np.argsort(2*new_b)
plt.plot( new_b, data, '*', color = Color)
plt.xlabel("Phase")
plt.ylabel("Magnitude")
plt.gca().invert_yaxis()
When calculating the features of a light-curve, the output can be returned in three different formats:
The following example shows how to implement the first option:
a.result(method='dict')
The next section details the features that we have developed in order to represent the light-curves. Every feature is described and tested with a suitable experiment to prove its validity.
Note: Each feature was also tested to check its invariance to unequal sampling. This refers to the fact that the telescope observations are not always taken at uniformly spaced intervals. Evidently, light-curve descriptors should be insensitive to this nonuniformity. The tests can be found in the following link.
Mean magnitude of the blue band. For a normal distribution it should take a value close to 0:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Bmean'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
The standard deviation $\sigma$ of the sample is defined as:
$$\sigma=\sum_{i} \frac{(y_{i}-\hat{y})^2}{N-1}$$
a = FeatureSpace(featureList=['Std'])
a=a.calculateFeature(data)
print a.result(method='dict')
For example, a white noise time serie should have $\sigma=1$
data2 = np.random.normal(size=1000000)
a = FeatureSpace(featureList=['Std' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
$R_{cs}$ is the range of a cumulative sum (Ellaway 1978) of each light-curve and is defined as:
$$R_{cs} = max(S) - min(S)$$ $$S_l = \frac{1}{N \sigma} \sum_{i=1}^l \left( m_i - \bar{m} \right) $$
where max(min) is the maximum (minimum) value of S and $l=1,2, \dots, N$.
$R_{cs}$ should take a value close to zero for a normal distribution:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Rcs'] )
a=a.calculateFeature(data)
print a.result(method='dict')
The Lomb-Scargle (L-S) algorithm (Scargle, 1982) is a variation of the Discrete Fourier Transform (DFT), in which a time series is decomposed into a linear combination of sinusoidal functions. The basis of sinusoidal functions transforms the data from the time domain to the frequency domain. DFT techniques often assume evenly spaced data points in the time series, but this is rarely the case with astrophysical time-series data. Scargle has derived a formula for transform coefficients that is similiar to the DFT in the limit of evenly spaced observations. In addition, an adjustment of the values used to calculate the transform coefficients makes the transform invariant to time shifts.
The Lomb-Scargle periodogram is optimized to identify sinusoidal-shaped periodic signals in time-series data. Particular applications include radial velocity data and searches for pulsating variable stars. L-S is not optimal for detecting signals from transiting exoplanets, where the shape of the periodic light-curve is not sinusoidal.
Next, we perform a test on synthetical data to confirm the accuracy of the period found by the L-S method:
Color = [ 1 ,0.498039, 0.313725];
N=100
mjd3 = np.arange(N)
Period = 20
cov = np.zeros([N,N])
mean = np.zeros(N)
for i in np.arange(N):
for j in np.arange(N):
cov[i,j] = np.exp( -(np.sin( (np.pi/Period) *(i-j))**2))
data3=np.random.multivariate_normal(mean, cov)
plt.plot(mjd3,data3, color=Color)
a = FeatureSpace(featureList=['PeriodLS'],PeriodLS=mjd3)
a=a.calculateFeature(data3)
print a.result(method='array')/Period, a.result(method='array'), Period
We can also confirm the validity of this result by folding the light-curve as explained in the introduction.
Color = [ 0.392157, 0.584314 ,0.929412];
T = 2 * a.result(method='array')
new_b=np.mod(mjd3, T) / T;
idx=np.argsort(2*new_b)
plt.plot( new_b, data3,'*', color=Color)
#plt.plot(np.sort(new_b), data3[np.argsort(new_b)],'*', color='red')
Returns the false alarm probability of the largest periodogram value. Let's test it for a normal distributed data and for a periodic one:
data2 = np.random.normal(size=1000)
mjd2=np.arange(1000)
a = FeatureSpace(featureList=['PeriodLS','Period_fit'], PeriodLS=mjd2)
a=a.calculateFeature(data2)
print "Normal data:", a.result(method='dict')
a = FeatureSpace(featureList=['PeriodLS','Period_fit'], PeriodLS=mjd3)
a=a.calculateFeature(data3)
print "Periodic data:", a.result(method='dict')
$R_{CS}$ applied to the phase-folded light curve (generated using the period estimated from the Lomb-Scargle method).
a = FeatureSpace(featureList=['PeriodLS','Psi_CS'], PeriodLS=mjd3, Psi_CS =mjd3 )
a=a.calculateFeature(data3)
print a.result(method='dict')
The color is defined as the difference between the average magnitude of the blue band and the red band observations. The value should be around zero.
a = FeatureSpace(featureList=['B_R' ],B_R=second_data )
a=a.calculateFeature(data)
print a.result(method='dict')
The autocorrelation, also known as serial correlation, is the cross-correlation of a signal with itself. Informally, it is the similarity between observations as a function of the time lag between them. It is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the missing fundamental frequency in a signal implied by its harmonic frequencies.
For an observed series $y_1, y_2,\dots,y_T$ with sample mean $\bar{y}$, the sample lag$-h$ autocorrelation is given by:
$$\hat{\rho}_h = \frac{\sum_{t=h+1}^T (y_t - \bar{y})(y_{t-h}-\bar{y})}{\sum_{t=1}^T (y_t - \bar{y})^2}$$
Since the autocorrelation fuction of a light curve is given by a vector and we can only return one value as a feature, we find the lag value where the autocorrelation function is smaller than $e^{-1}$.
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Autocor'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
In slotted autocorrelation, time lags are defined as intervals or slots instead of single values. The slotted autocorrelation function at a certain time lag slot is computed by averaging the cross product between samples whose time differences fall in the given slot.
$$\hat{\rho}(\tau=kh) = \frac {1}{\hat{\rho}(0)\,N_\tau}\sum_{t_i}\sum_{t_j= t_i+(k-1/2)h }^{t_i+(k+1/2)h } \bar{y}_i(t_i)\,\, \bar{y}_j(t_j) $$
In order to check the validity of this feature let's calculate the slotted autocorrelation for a normal distribution with T=1 and compare it with the autocorrelation function.
data2 = np.random.normal(size=1000)
mjd2=np.arange(1000)
Color = [ 0.392157, 0.584314 ,0.929412];
Color2 = [ 1 ,0.498039, 0.313725];
plt.figure(figsize=(10,5))
SAC = slotted_autocorrelation(data2, mjd2, 1, 100)
a, = plt.plot(SAC[0:40], '*', color=Color, markersize=10)
AC = stattools.acf(data2)
b, =plt.plot(AC, color=Color2)
plt.legend([a, b],['Slotted autocorrelation', 'Autocorrelation'])
data2 = np.random.normal(size=1000)
mjd2=np.arange(1000)
AC = stattools.acf(data2)
k = next((index for index,value in enumerate(AC) if value < np.exp(-1)), None)
print "From the autocorrealtion function:", k
a = FeatureSpace(featureList=['SlottedA'] , SlottedA = [mjd2, 1])
a=a.calculateFeature(data2)
print a.result(method='dict')
These three features are based on the Welch/Stetson variability index $I$ defined by the equation: $$ I = \sqrt{\frac{1}{n(n-1)}} \sum_{i=1}^n {\left( \frac{b_i-\hat{b}}{\sigma_{b,i}}\right) \left( \frac{v_i - \hat{v}}{\sigma_{v,i}} \right)} $$
where $b_i$ and $v_i$ are the apparent magnitudes obtained for the candidate star in two observations closely spaced in time on some occasion $i$, $\sigma_{b,i}$ and $\sigma_{v,i}$ are the standard errors of those magnitudes, $\hat{b}$ and $\hat{v}$ are the weighted mean magnitudes in the two filters, and $n$ is the number of observation pairs.
Since a given frame pair may include data from two filters which did not have equal numbers of observations overall, the "relative error" is calculated as follows:
$$ \delta = \sqrt{\frac{n}{n-1}} \frac{v-\hat{v}}{\sigma_v} $$
allowing all residuals to be compared on an equal basis.
Stetson K is a robust kurtosis measure: $$ \frac{1/N \sum_{i=1}^N |\delta_i|}{\sqrt{1/N \sum_{i=1}^N \delta_i^2}}$$
where the index $i$ runs over all $N$ observations available for the star without regard to pairing. For a Gaussian magnitude distribution K should take a value close to $\sqrt{2/\pi} = 0.798$, let's test it:
data2 = np.random.normal(size=1000)
a = FeatureSpace(featureList=['StetsonK' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
Stetson K applied to the slotted autocorrelation function of the light-curve.
mjd2=np.arange(1000)
a = FeatureSpace(featureList=['StetsonK_AC' ])
a=a.calculateFeature(data2)
print a.result(method='dict')
Stetson J is a robust version of the variability index. It is calculated based on two simultaneous light curves of a same star and is defined as:
$$ J = \sum_{k=1}^n sgn(P_k) \sqrt{|P_k|}$$
with $P_k = \delta_{i_k} \delta_{j_k} $
For a Gaussian magnitude distribution, J should take a value close to zero:
data2 = np.random.normal(size=10000)
data3 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['StetsonJ' ], StetsonJ=[data3, data2])
a=a.calculateFeature(data2)
print a.result(method='dict')
Stetson L variability index describes the synchronous variability of different bands and is defined as: $$ L = \frac{JK}{0.798} $$
Again, for a Gaussian magnitude distribution, L should take a value close to zero:
data2 = np.random.normal(size=10000)
data3 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['StetsonL' ], StetsonL=[data3, data2])
a=a.calculateFeature(data2)
print a.result(method='dict')
Variability index $\eta$ is the ratio of the mean of the square of successive differences to the variance of data points. The index was originally proposed to check whether the successive data points are independent or not. In other words, the index was developed to check if any trends exist in the data (von Neumann 1941). It is defined as: $$\eta=\frac{1}{\left(N-1 \right)\sigma^2}\sum_{i=1}^{N-1} \left( m_{i+1}-m_i \right)^2 $$
The variability index should take a value close to 2 for a normal distribution:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['VariabilityIndex' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
Although $\eta$ is a poweful index for quantifying variability characteristics of a time series, it does not take into account unequal sampling. Thus $\eta^e$ is defined as:
$$ \eta^e = \bar{w} \left( t_{N-1} - t_1 \right)^2 \frac{\sum_{i=1}^{N-1} w_i \left(m_{i+1} - m_i \right)^2}{\sigma^2 \sum_{i=1}^{N-1} w_i} $$
$$ w_i = \frac{1}{\left( t_{i+1} - t_i \right)^2} $$
data2 = np.random.normal(size=10000)
mjd2=np.arange(10000)
a = FeatureSpace(featureList=['Eta_e' ], Eta_e = mjd2 )
a=a.calculateFeature(data2)
print a.result(method='dict')
$\eta^e$ index calculated from the B − R light curve.
data3 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Eta_B_R' ], Eta_B_R = [data3, data2, mjd2] )
a=a.calculateFeature(data2)
print a.result(method='dict')
$\eta$ index calculated from the folded light curve.
data2 = np.random.normal(size=1000)
mjd2=np.arange(1000)
a = FeatureSpace(featureList=['PeriodLS','Psi_eta'], PeriodLS = mjd2)
a=a.calculateFeature(data2)
print a.result(method='dict')
Small sample kurtosis of the magnitudes: $$ Kurtosis = \frac{N \left( N+1 \right)}{\left( N-1 \right) \left( N-2 \right) \left( N-3 \right)} \sum_{i=1}^N \left( \frac{m_i-\hat{m}}{\sigma} \right)^4 - \frac{3\left( N-1 \right)^2}{\left( N-2 \right) \left( N-3 \right)} $$
For a normal distribution, the small kurtosis should be zero:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['SmallKurtosis' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
The skewness of a sample is defined as follow: $$ Skewness = \frac{N}{\left(N-1\right)\left(N-2\right)} \sum_{i=1}^N \left( \frac{m_i-\hat{m}}{\sigma}\right)^3 $$
For a normal distribution it should be equal to zero:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Skew' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
The median absolute deviation is defined as the median discrepancy of the data from the median data:
$$Median Absolute Deviation = median\left( |mag - median(mag)|\right) $$
It should take a value close to 0.675 for a normal distribution:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['MedianAbsDev' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
The amplitude is defined as the half of the difference between the mean of the maximum 5% and the mean of the minimum 5% magnitudes. For a sequence of numbers from 0 to 1000 the amplitude should be equal to 475.5:
data2 = range(1000)
a = FeatureSpace(featureList=['Amplitude' ] )
a=a.calculateFeature(data2)
print a.result(method='dict')
Index introduced for the selection of variable stars from the OGLE database (Wozniak 2000). To calculate Con, we count the number of three consecutive data points that are brighter or fainter than $2\sigma$ and normalize the number by $N-2$.
For a normal distribution and by considering just one star, Con should take values close to 0.045:
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Con' ] , Con=1)
a=a.calculateFeature(data2)
print a.result(method='dict')
The Anderson-Darling test is a statistical test of whether a given sample of data is drawn from a given probability distribution. When applied to testing if a normal distribution adequately describes a set of data, it is one of the most poweful statistical tools for detecting most departures from normality.
For a normal distribution the Anderson-Darling statistic should take values close to 0.25:
b=[]
for i in xrange(5000):
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['AndersonDarling' ] )
a=a.calculateFeature(data2)
b.extend(a.result())
fig = plt.hist(b)
Slope of a linear fit to the light-curve.
data2 = np.random.normal(size=10000)
mjd2=np.arange(10000)
a = FeatureSpace(featureList=['LinearTrend'] ,LinearTrend = mjd2 )
a=a.calculateFeature(data2)
print a.result(method='dict')
Maximum absolute magnitude slope between two consecutive observations
data2 = np.random.normal(size=1000)
mjd2=np.arange(1000)
a = FeatureSpace(featureList=['MaxSlope'] , MaxSlope = mjd2 )
a=a.calculateFeature(data2)
print a.result(method='dict')
Percentage of points beyond one standard deviation from the weighted mean.
For a normal distribution, it should take a value close to 0.32:
data2 = np.random.normal(size=10000)
error2 = np.random.normal(loc=0.01, scale =0.01, size=10000)
a = FeatureSpace(featureList=['Beyond1Std'] , Beyond1Std = error2 )
a=a.calculateFeature(data2)
print a.result(method='dict')
Considering the last 30 (time-sorted) measurements of source magnitude, the fraction of increasing first differences minus the fraction of decreasing first differences.
data2 = np.random.normal(size=100000)
a = FeatureSpace(featureList=['PairSlopeTrend'])
a=a.calculateFeature(data2)
print a.result(method='dict')
In order to caracterize the sorted magnitudes distribution we use percentiles. If $F_{5,95}$ is the difference between $95\%$ and $5\%$ magnitude values, we calculate the following:
For the first feature for example, in the case of a normal distribution, this is equivalente to calculate $\frac{erf^{-1}(2 \cdot 0.6-1)-erf^{-1}(2 \cdot 0.4-1)}{erf^{-1}(2 \cdot 0.95-1)-erf^{-1}(2 \cdot 0.05-1)}$. So, the expected values for each of the flux percentile features are:
data2 = np.random.normal(size=100000)
a = FeatureSpace(featureList=['FluxPercentileRatioMid20','FluxPercentileRatioMid35','FluxPercentileRatioMid50','FluxPercentileRatioMid65','FluxPercentileRatioMid80'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
$Q_{3-1}$ is the difference between the third quartile, $Q_3$, and the first quartile, $Q_1$, of a raw light curve. $Q_1$ is a split between the lowest $25\%$ and the highest $75\%$ of data. $Q_3$ is a split between the lowest $75\%$ and the highest $25\%$ of data.
data2 = np.random.normal(size=100000)
a = FeatureSpace(featureList=['Q31'])
a=a.calculateFeature(data2)
print a.result(method='dict')
$Q_{3-1}$ applied to the difference between both bands of a light curve (B-R).
data2 = np.random.normal(size=10000)
data3 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['Q31B_R'] , Q31B_R = [data3, data2])
a=a.calculateFeature(data2)
print a.result(method='dict')
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['PercentDifferenceFluxPercentile'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
Largest percentage difference between either the max or min magnitude and the median.
data2 = np.random.normal(size=10000)
a = FeatureSpace(featureList=['PercentAmplitude'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
This is a simple variability index and is defined as the ratio of the standard deviation, $\sigma$, to the mean magnitude, $\bar{m}$. If a light curve has strong variability, $\frac{\sigma}{\bar{m}}$ of the light curve is generally large.
For a uniform distribution the mean-variance should take a value close to 0.577:
data2 = np.random.uniform(size=1000000)
a = FeatureSpace(featureList=['Meanvariance'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
Fraction of photometric points within amplitude/10 of the median magnitude.
data2 = np.random.normal(size=1000000)
a = FeatureSpace(featureList=['MedianBRP'] )
a=a.calculateFeature(data2)
print a.result(method='dict')
In order to model the irregular sampled times series we use CAR(1), a continious time auto regressive model. CAR(1) process has three parameters, it provides a natural and consistent way of estimating a characteristic time scale and variance of light-curves. CAR(1) process is described by the following stochastic differential equation:
$$ dX(t) = - \frac{1}{\tau} X(t)dt + \sigma_C \sqrt{dt} \epsilon(t) + bdt, $$ $$for \: \tau, \sigma_C, t \geq 0 $$
where the mean value of the lightcurve $X(t)$ is $b\tau$ and the variance is $\frac{\tau\sigma_C^2}{2}$. $\tau$ is the relaxation time of the process $X(T)$, it can be interpreted as describing the variability amplitude of the time series. $\sigma_C$ can be interpreted as describing the variability of the time series on time scales shorter than $\tau$. $\epsilon(t)$ is a white noise process with zero mean and variance equal to one. The likelihood function of a CAR(1) model for a light-curve with observations $x - \{x_1, \dots, x_n\}$ observed at times $\{t_1, \dots, t_n\}$ with measurements error variances $\{\delta_1^2, \dots, \delta_n^2\}$ is:
$$ p \left( x|b,\sigma_C,\tau \right) = \prod_{i=1}^n \frac{1}{[2 \pi \left( \Omega_i + \delta_i^2 \right)]^{1/2}} exp \{ -\frac{1}{2} \frac{\left( \hat{x}_i - x^*_i \right)^2}{\Omega_i + \delta^2_i} \} $$ $$ x_i^* = x_i - b\tau$$ $$ \hat{x}_0 = 0 $$ $$ \Omega_0 = \frac{\tau \sigma^2_C}{2} $$ $$ \hat{x}_i = a_i\hat{x}_{i-1} + \frac{a_i \Omega_{i-1}}{\Omega_{i-1} + \delta^2_{i-1}} \left(x^*_{i-1} + \hat{x}_{i-1} \right) $$ $$ \Omega_i = \Omega_0 \left( 1- a_i^2 \right) + a_i^2 \Omega_{i-1} \left(1 - \frac{\Omega_{i-1}}{\Omega_{i-1} + \delta^2_{i-1}} \right) $$ $$ a_i = e^{-\left(t_i-t_{i-1}\right)/\tau} $$
To find the optimal parameters we maximize the likelihood with respect to $\sigma_C$ and $\tau$ and calculate $b$ as the mean magnitude of the light-curve divided by $\tau$.
data2 = np.random.normal(scale=3, size=1000)
mjd2=np.arange(1000)
error2 = np.random.normal(loc=0.01, scale =0.8, size=1000)
a = FeatureSpace(featureList=['CAR_sigma', 'CAR_tau','CAR_tmean'] , CAR_sigma = [mjd2,error2] )
a=a.calculateFeature(data2)
print a.result(method='dict')
print np.var(data2), (15.95)**2 * 0.071/2
In order to check systematically the validity of each feature, every test mentioned above is added to a unit test file called "test_library.py". This script should be always ran before using the library by executing $ py.test. Also, if the user writes a new feature for the library, a pertinent test should be added to the unit test file. The idea is to guarantee, as far as possible, that every feature calculated is correct. In most of the cases this can be reached by calculating the expected feature value for a known distribution (normal, uniform, etc) and then by checking with the value obtained from the library.
The following image shows how py.test output should look if all the tests are passed:
Image(filename='unit2.png')
[1] Falk, M., Marohn, F., Michel, R., Hofmann, D., Macke, M., Tewes, B., ... & Englert, S. (2011). A First Course on Time Series Analysis: Examples with SAS. An open source book on time series analysis with SAS.
[2] Kim, D. W., Protopapas, P., Alcock, C., Byun, Y. I., & Bianco, F. (2009). De-Trending Time Series for Astronomical Variability Surveys. Monthly Notices of the Royal Astronomical Society, 397(1), 558-568. Doi:10.1111/j.1365-2966.2009.14967.x.
[3] Kim, D. W., Protopapas, P., Byun, Y. I., Alcock, C., Khardon, R., & Trichas, M. (2011). Quasi-stellar object selection algorithm using time variability and machine learning: Selection of 1620 quasi-stellar object candidates from MACHO Large Magellanic Cloud database. The Astrophysical Journal, 735(2), 68. Doi:10.1088/0004-637X/735/2/68.
[4] Kim, D. W., Protopapas, P., Bailer-Jones, C. A., Byun, Y. I., Chang, S. W., Marquette, J. B., & Shin, M. S. (2014). The EPOCH Project: I. Periodic Variable Stars in the EROS-2 LMC Database. arXiv preprint Doi:10.1051/0004-6361/201323252.
[5] Pichara, K., Protopapas, P., Kim, D. W., Marquette, J. B., & Tisserand, P. (2012). An improved quasar detection method in EROS-2 and MACHO LMC data sets. Monthly Notices of the Royal Astronomical Society, 427(2), 1284-1297. Doi:10.1111/j.1365-2966.2012.22061.x.
[6] Richards, J. W., Starr, D. L., Butler, N. R., Bloom, J. S., Brewer, J. M., Crellin-Quick, A., ... & Rischard, M. (2011). On machine-learned classification of variable stars with sparse and noisy time-series data. The Astrophysical Journal, 733(1), 10. Doi:10.1088/0004-637X/733/1/10.
picture = Image(filename='peanuts.jpg')
picture.size = (30, 30)
picture